﻿Ext.namespace("Swfu");
Ext.namespace("Swfu.BackMgr");
function SetCookie(name, value) {
    var Days = 30;
    var exp = new Date();
    exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);
    document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString()
}
function getCookie(name) {
    var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
    if (arr != null) {
        return unescape(arr[2]);
    }
    return "ext-all.css"
}
Ext.ux.ThemeChange = Ext.extend(Ext.form.ComboBox,
{
    editable: false, displayField: 'theme', valueField: 'css', typeAhead: true, mode: 'local', triggerAction: 'all',
    selectOnFocus: true,
    initComponent: function () {
        var theme = [['默认', 'ext-all.css'], ['黑色', 'xtheme-black.css'], ['巧克力', 'xtheme-chocolate.css'],
        ['深灰色', 'xtheme-darkgray.css'], ['粉色', 'xtheme-pink.css'], ['浅灰色', 'xtheme-gray.css'], ['墨绿',
        'xtheme-green.css'], ['靛青色', 'xtheme-indigo.css'], ['深夜', 'xtheme-midnight.css'], ['椒盐色', 'xtheme-peppermint.css'],
        ['紫色', 'xtheme-purple.css'], ['银白色', 'xtheme-silverCherry.css'], ['暗蓝', 'xtheme-slate.css'], ['Vista',
        'xtheme-slickness.css']];
        this.store = new Ext.data.SimpleStore({
            fields: ['theme', 'css'], data: theme
        });
        this.value = getCookie("cssSheet");
        Ext.util.CSS.swapStyleSheet('theme', '../Content/scripts/extjs/resources/css/' + getCookie("cssSheet"))
    },
    initEvents: function () {
        this.on('collapse', function () {
            Ext.util.CSS.swapStyleSheet('theme', '../Content/scripts/extjs/resources/css/' + this.getValue());
            SetCookie("cssSheet", this.getValue())
        })
    }
});
Ext.reg('ThemeChange', Ext.ux.ThemeChange);